package cn.mavor.day0929.bufferedReader;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class CountLinesUsingReadLine {
    public static int countLines(String filePath) throws IOException {
        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;
            int lines = 0;
            while ((line = reader.readLine()) != null) {
                lines++;
            }
            return lines;
        }
    }
}